package com.bishe.demo.modules.hotel.hotelMain.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.common.entity.SearchBean;
import com.bishe.demo.modules.hotel.hotelMain.entity.HotelMain;
import com.bishe.demo.modules.hotel.hotelMain.service.HotelMainService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class HotelMainController {
    @Autowired
    private HotelMainService hotelMainService;

    @PostMapping(value = "/hotelMain", consumes = "application/json")
    public ResultEntity<HotelMain> insertHotelMain(@RequestBody HotelMain hotelMain) {
        return hotelMainService.insertHotelMain(hotelMain);
    }

    @GetMapping(value = "/hotelMains")
    public List<HotelMain> getHotelMains() {
        return hotelMainService.getHotelMains();
    }

    @GetMapping("/hotelMains/{province}")
    List<HotelMain> getHotelMainsByProvince(@PathVariable int province) {
        return hotelMainService.getHotelMainsByProvince(province);
    }

    @GetMapping("/hotelMains/v2/{city}")
    List<HotelMain> getHotelMainsByCity(@PathVariable int city) {
        return hotelMainService.getHotelMainsByCity(city);
    }

    @GetMapping("/hotelMains/v3/{area}")
    List<HotelMain> getHotelMainByArea(@PathVariable int area) {
        return hotelMainService.getHotelMainByArea(area);
    }

    @GetMapping("/hotelMains/v4/{hotelId}")
    HotelMain getHotelMainByHotelId(@PathVariable int hotelId) {
        return hotelMainService.getHotelMainByHotelId(hotelId);
    }

    @GetMapping("/hotelMain/{userId}")
    HotelMain getHotelMainById(@PathVariable int userId) {
        return hotelMainService.getHotelMainById(userId);
    }

    @PutMapping(value = "/hotelMain", consumes = "application/json")
    ResultEntity<HotelMain> updateHotelMain(@RequestBody HotelMain hotelMain) {
        return hotelMainService.updateHotelMain(hotelMain);
    }

    @DeleteMapping("/hotelMain/{hotelId}")
    ResultEntity<HotelMain> deleteHotelMain(@PathVariable int hotelId) {
        return hotelMainService.deleteHotelMain(hotelId);
    }

    @PostMapping(value = "/hotels", consumes = "application/json")
    public PageInfo<HotelMain> getHotelsBySearchBeans(@RequestBody SearchBean searchBean) {
        return hotelMainService.getHotelsBySearchBeans(searchBean);
    }

    @GetMapping("/hotels")
    List<HotelMain> getHotelMainsForMain() {
        return hotelMainService.getHotelMainsForMain();
    }
}
